package cn.zswltech.gruul.biz.service.impl;

import cn.zswltech.gruul.biz.service.ScheduledService;
import org.springframework.stereotype.Service;

/**
 * 定时任务
 *
 * @Author: Jason
 * @Date: 2020/2/5 下午4:29
 */
@Service("scheduledService")
public class ScheduledServiceImpl implements ScheduledService {
//    private final static Logger logger = LoggerFactory.getLogger(ScheduledServiceImpl.class);
//
//    /**
//     * 操作日志清理开关，true开,false关
//     */
//    @Value("${bifrost.operation.log.switch}")
//    private boolean operationLogSwitch;
//
//    /**
//     * 操作日志保留天数，过期将会被清除，默认90天
//     */
//    @Value("${bifrost.operation.log.expires}")
//    private int operationLogExpires;
//
//    /**
//     * 操作日志记录最大数量，超过将会被清除，默认500万
//     */
//    @Value("${bifrost.operation.log.max}")
//    private int operationLogMax;

//    @Autowired
//    private UserOperationHistoryDOMapper userOperationHistoryDOMapper;


//    /**
//     * 清理操作日志
//     */
//    @Override
//    public void cleanOperationLog() {
////        if (!operationLogSwitch) {
////            return;
////        }
////        if (operationLogExpires == 0) {
////            operationLogExpires = 90;
////        }
////        if (operationLogMax == 0) {
////            operationLogMax = 5000000;
////        }
////        try {
////            logger.info("operationLogExpires:{},operationLogMax:{}", operationLogExpires, operationLogMax);
////            // 清理过期数据
////            int expiresCount = userOperationHistoryDOMapper.deleteExpiresData(operationLogExpires);
////            if (expiresCount > 0) {
////                Calendar ca = Calendar.getInstance();
////                ca.add(Calendar.DATE, 0 - operationLogExpires);
////                logger.info("Delete expires data count : {}, expires time : {}", expiresCount, DateUtils.formatFullDate(ca.getTime()));
////            }
////            // 清理超过最大数量限制的数据
////            UserOperationQuery query = new UserOperationQuery();
////            int totalCount = userOperationHistoryDOMapper.queryPageCount(query);
////            if (totalCount > operationLogMax) {
////                int maxCount = userOperationHistoryDOMapper.deleteMaxData(totalCount - operationLogMax);
////                if (maxCount > 0) {
////                    logger.info("Delete max limit data count : {}", maxCount);
////                }
////            }
////        } catch (Exception e) {
////            logger.error("Clean operation log error", e);
////        }
//
//    }
}
